package org.inspursc.s0517.health.common.controller;

import org.inspursc.s0517.health.common.entity.SysLog;
import org.inspursc.s0517.health.common.service.SysLogService;
import org.inspursc.s0517.health.common.util.ResponseUtil;
import org.inspursc.s0517.health.common.vo.PageVO;
import org.inspursc.s0517.health.common.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yuchu
 */
@RestController
@RequestMapping("log")
public class SysLogController {

    @Autowired
    private SysLogService logService;

    @RequestMapping("/getLog")
    public ResponseEntity<ResponseVO> getLog(@RequestParam Integer pageIndex,@RequestParam Integer pageSize){
        Pageable pageable = PageRequest.of(pageIndex - 1, pageSize);
        Page<SysLog> page=logService.findAll(pageable);
        PageVO pageVO = new PageVO(page.getContent(), page.getTotalPages(), page.getTotalElements(), pageIndex);
        return ResponseUtil.success(pageVO);
    }
}
